﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Input;

namespace GlobalizationTools.UI
{
    public abstract class CommandViewModel : INotifyPropertyChanged, ICommandContext
    {
        List<CommandBinding> _commandList;
        private static string _statusText = string.Empty;

        public List<CommandBinding> Commands
        {
            get
            {
                if (_commandList == null)
                {
                    _commandList = new List<CommandBinding>();
                    this.AddCommandModels(_commandList);
                }

                return _commandList;
            }
        }

        public abstract void AddCommandModels(List<CommandBinding> List);
        
        List<InputBinding> _inputList;

        public List<InputBinding> Inputs
        {
            get
            {
                if (_inputList == null)
                {
                    _inputList = new List<InputBinding>();
                    this.AddInputModels(_inputList);
                }

                return _inputList;
            }
        }

        public abstract void AddInputModels(List<InputBinding> List);
        
        ///<summary>
        ///PropertyChanged event for INotifyPropertyChanged implementation.
        ///</summary>
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        
        public string StatusText
        {
            get
            {
                return _statusText;
            }
            set
            {
                if (_statusText != value)
                {
                    _statusText = value;
                    this.OnPropertyChanged("StatusText");
                }
            }
        }
    }
}
